package com.alm.token.api;
//
//
//import android.app.Application;
//
//import com.alm.token.BuildConfig;
//import com.alm.token.ConStant;
//import com.alm.token.MyApp;
//import com.alm.token.MyAppGlideModule;
//import com.alm.token.utils.SpUtil;
//
//import java.io.IOException;
//import java.util.concurrent.TimeUnit;
//
//import okhttp3.Interceptor;
//import okhttp3.OkHttpClient;
//import okhttp3.Request;
//import okhttp3.Response;
//import okhttp3.logging.HttpLoggingInterceptor;
//import retrofit2.Retrofit;
//import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
//import retrofit2.converter.gson.GsonConverterFactory;
//
///**
// * 网络数据配置客户端
// */
public class AppClient {
//    public static Retrofit mRetrofit;
//    private static String Content_Type = "application/x-www-form-urlencoded";
//    private static String Token = "";
//
//    public static Retrofit retrofit() {
//        if (mRetrofit == null) {
//            OkHttpClient.Builder builder = new OkHttpClient.Builder();
//
//            if (BuildConfig.DEBUG) {
//                // Log信息拦截器
//                HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
//                loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
//                //设置 Debug Log 模式
//                builder.addInterceptor(loggingInterceptor);
//            }
////            OkHttpClient okHttpClient = builder.build();
//            mRetrofit = new Retrofit.Builder()
//                    .baseUrl(ConStant.HOST)
//                    .addConverterFactory(GsonConverterFactory.create())
//                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
//                    .client(genericClient())
//                    .build();
//        }
//        return mRetrofit;
//    }
//
//    public static OkHttpClient genericClient() {
//        OkHttpClient httpClient = new OkHttpClient.Builder()
//                .connectTimeout(30000, TimeUnit.SECONDS)
//                .readTimeout(30000, TimeUnit.SECONDS)
//                .addInterceptor(new Interceptor() {
//                    @Override
//                    public Response intercept(Chain chain) throws IOException {
//                        Request request;
//                        if (MyApp.Token.isEmpty()) {
//                            request = chain.request()
//                                    .newBuilder()
//                                    .addHeader("Content-Type", Content_Type)
//                                    .build();
//                        } else {
//                            request = chain.request()
//                                    .newBuilder()
//                                    .addHeader("Content-Type", Content_Type)
//                                    .addHeader("token", Token = MyApp.Token)
//                                    .build();
//                        }
//
//                        return chain.proceed(request);
//                    }
//                })
//                .addInterceptor(new AddCookiesInterceptor()) //这部分
//                .addInterceptor(new ReceivedCookiesInterceptor()) //这部分
//                .build();
//
//
//        return httpClient;
//    }
}
